package com.zigong.app.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.zigong.app.R;
import com.zigong.app.beans.ConvertRecordBean;
import com.zigong.app.ui.adapter.holder.ConvertRecordHolder;

import java.util.List;

/**
 * Created by Liuyu on 2018/8/17.
 */

public class ConvertRecordAdapter extends BaseHolderAbsAdapter<ConvertRecordBean, ConvertRecordHolder> {

    public ConvertRecordAdapter(Context context, List<ConvertRecordBean> list) {
        super(context, list);
    }

    @Override
    public ConvertRecordHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_convert_record, parent, false);
        ConvertRecordHolder crh = new ConvertRecordHolder(context, v);
        return crh;
    }

    @Override
    public void onBindViewHolder(ConvertRecordHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.setOther(position == getItemCount() - 1);
    }

    @Override
    public void addDatas(List<ConvertRecordBean> list) {
        int old = getItemCount();
        super.addDatas(list);
        if (old != getItemCount()) {
            notifyItemChanged(old - 1);
        }
    }
}
